#pragma once
#include<cstdint>
#include<functional>
#include<memory>

namespace tmms{
    namespace base{
        class Task;//定时任务
        using TaskPtr = std::shared_ptr<Task>;
        using TaskCallback = std::function<void(const TaskPtr&)>;
        class Task:public std::enable_shared_from_this<Task>
        {

        public:
            Task(const TaskCallback &vb,int64_t Interval);//左值引用
            Task(const TaskCallback &&vb,int64_t Interval);//右值引用
            void Run();
            void Restart();
            int64_t When()const{
                return when_;
            }   
        private:
            int64_t interval_{0};
            int64_t when_{0};
            TaskCallback cb_;
        };
    }


}